#include <iostream>
#include <sstream>

#include <gtest/gtest.h>

#include "melon/client/thrift_client_pool.h"
#include "obbt/adapters/obbt_message_history_adapter.h"

using melon::client::ClientPool;

using namespace obbt;

TEST(T, T) {
  for(int i = 0; i < 10000; ++i) {
    int64_t engineer = time(NULL);
    int64_t customer = 1;

    std::vector<std::string> messages;
    int ret = ObbtMessageHistoryAdapter::Instance().GetMessageWithLimit(customer, engineer,
        0, 5, &messages, 3);

    std::cout << "GetMessageWithLimit ret=" << ret << std::endl;
  }
}

struct Args {
  Args(int c, char ** v) : argc(c), argv(v) {}
  int argc;
  char** argv;
};
void * ThreadFun(void * p) {
  Args * args = (Args*)p;
  testing::InitGoogleTest(&args->argc, args->argv);
  return (void*)RUN_ALL_TESTS();
}

const int kThreadCount = 1;

int main(int argc, char** argv) {
  LOG_INIT("./obbt_assignment_audit_test.log", "DEBUG");
  pthread_t ts[kThreadCount];

  Args args(argc, argv);
  for (int i = 0; i < kThreadCount; ++i) {
    pthread_create(&ts[i], NULL, ThreadFun, &args);
  }

  for (int i = 0; i < kThreadCount; ++i) {
    pthread_join(ts[i], NULL);
  }
  return 0;
} 

